{% extends "base.html" %}

{% block content %}
    {% if posts %}

    {% for post in posts %}
        {% if post.visible %}
            <h5 style="margin-left: 100px;"><a class="text-info" href="/post/{{ post.title }}/">{{ post.title }}</a></h5>
            <small>{{ post.summary }}</small>
            <small>
                <ul class="list-inline text-right">
                    <li>
                        Posted @
                        <a href="/date/{{ post.publish_datetime|date:'Y/m/d' }}/">
                            {{ post.publish_datetime }}
                        </a>
                    </li>
                <li>|</li>
                    <li>{{ post.status }}</li>
                <li>|</li>
                    <li>
                        {% for tag in post.post_tag_list %}
                            <a href="/tag/{{ tag }}/">{{ tag }}</a>
                            {% if not forloop.last %}
                                ,
                            {% endif %}
                        {% endfor %}
                    </li>
                <li>|</li>
                    <li>
                        <a href="/category/{{ post.category }}/">{{ post.category }}</a>
                    </li>
                <li>|</li>
                    <li>{{ post.view_count }} views</li>
                {% if isAdminUser %}
                <li>|</li>
                    <li> <a href="/admin/blog/post/{{ post.id }}/">edit</a> </li>
                {% endif %}
                </ul>
            </small>
            <hr/>
        {% endif %}
    {% endfor %}
    <div style="text-align:center">
        <ul class="pagination pagination-centered pagination-sm">
            {% if posts.has_previous %}
                <li><a href="?page={{ posts.previous_page_number }}">«</a></li>
            {% else %}
                <li class="disabled"><a>«</a></li>
            {% endif %}
            {% for number in posts.paginator.page_range %}
                {% if number == posts.number %}
                    <li class="disabled"><a>{{ number }}</a></li>
                {% else %}
                    <li><a href="?page={{ number }}">{{ number }}</a></li>
                {% endif %}
            {% endfor %}
            {% if posts.has_next %}
                <li><a href="?page={{ posts.next_page_number }}">»</a></li>
            {% else %}
                <li class="disabled"><a>»</a></li>
            {% endif %}
        </ul>
    </div>
    {% else %}
        <p class="text-center text-danger">nothing is here.</p>
    {% endif %}
{% endblock content %}
